from django.db import models
from comment.models import Comment
from user.models import OrdinaryUser
# Create your models here.




class SparkCard(models.Model):
    STATUS_NORMAL = 1  # 正常的状态
    STATUS_DELETE = 0  # 删除的状态   ,没有负数！！！！
    STATUS_ITEMS = (
        (STATUS_NORMAL, '正常'),
        (STATUS_DELETE, '删除')
    )
    title = models.CharField(max_length=126, verbose_name='标题')
    spark_content = models.CharField(max_length=1024, verbose_name='灵感内容')
    created_time = models.DateTimeField(auto_now=True, verbose_name='创建时间')  # 为了以后修改卡片，所以这里设定为实时更新的时间
    like = models.PositiveIntegerField(verbose_name='点赞', default=0)
    status = models.PositiveIntegerField(default=STATUS_NORMAL, choices=STATUS_ITEMS, verbose_name='状态')  # 状态，一张卡片有正常和删除两种状态
    owner = models.ForeignKey(OrdinaryUser, verbose_name='发布者', on_delete=models.CASCADE)   # 当删除外键时，一并删除所属的各项信息
    comments = models.ForeignKey(Comment, verbose_name='评论', on_delete=models.CASCADE, default=Comment.DEFAULT_PK)  # 一张灵感卡片会对应着有多条评论,默认没有评论

    class Meta:
        verbose_name = verbose_name_plural = '灵感卡片'


